﻿//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Runtime.Serialization;
//using System.Runtime.Serialization.Formatters.Binary;
//using System.Text;

//namespace CoreEx.Common.Extensions
//{
//    public static class ObjectExtensions
//    {
//        public static T DeepClone<T>(this T target) 
//        {                        
//            using (MemoryStream memStream = new MemoryStream())
//            {
//                BinaryFormatter binaryFormatter = new BinaryFormatter(null,
//                     new StreamingContext(StreamingContextStates.Clone));
//                binaryFormatter.Serialize(memStream, target);
//                memStream.Seek(0, SeekOrigin.Begin);
                
//                return (T)binaryFormatter.Deserialize(memStream);
//            }
//        }
//    }
//}
